package com.thinkit.bigdata.web.listener;


import com.thinkit.bigdata.core.util.PropsUtil;
import com.thinkit.bigdata.web.coremet.SystemStatic;
import org.apache.log4j.Logger;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.util.Map;


/**
 * Created by BanAiQin on 2018/2/2.
 * ServletContext监听器，
 * 服务器重启时，开启文件夹监控线程
 */
public class MyContextListener implements ServletContextListener {

    private static Logger logger = Logger.getLogger(MyContextListener.class);

    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        logger.info("服务器重启......");
        SystemStatic.FTP_CONFIG_MAP = (Map)PropsUtil.readJsonConfigToMap("ftp.json");
        SystemStatic.PROVINCE_CITY_MAP = PropsUtil.readJsonConfigToMap("province-citys.json");
    }

    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
        logger.info("服务器关闭");
    }

}
